<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="personLayout.xhtml">

	<ui:define name="natPersonTlbMainControls">
		<rich:toolBar height="25" itemSeparator="line">
			<rich:toolBarGroup>
				<h:form>
					<h:outputText value="#{messages['txt.quick_search']}   " style="font-weight:bold;" />
					<h:selectOneMenu value="#{personHelper.searchSelector}">
						<f:selectItem itemValue="#{personHelper.BY_NATIONAL_ID}" itemLabel="Tarjeta de identidad"/>
						<f:selectItem itemValue="#{personHelper.BY_LASTNAMES}" itemLabel="Apellido (s)"/>
						<f:selectItem itemValue="#{personHelper.BY_FIRSTNAMES}" itemLabel="Nombre (s)"/>
						<f:selectItem itemValue="#{personHelper.BY_RTN}" itemLabel="RTN"/>
					</h:selectOneMenu>
					<h:outputText value="  " />
					<h:inputText value="#{personHelper.searchText}" />
					<h:outputText value="  " />
					<a4j:commandButton
						value="#{messages['txt.search']}"
						action="#{personHelper.quickSearch}"
						reRender="frmNatPersonGrid">
					</a4j:commandButton>
				</h:form>
			</rich:toolBarGroup>
			<rich:toolBarGroup>
				<h:form>
					<a4j:commandButton
						value="Agregar"
						action="#{personHelper.addNew}"
						reRender="frmEditNatPerson"
						oncomplete="#{rich:component('editNatPersonDlg')}.show();">
					</a4j:commandButton>
				</h:form>
			</rich:toolBarGroup>
		</rich:toolBar>
	</ui:define>
	
	<ui:define name="natPersonResultGrid">
		<h:form id="frmNatPersonGrid">
			<h:panelGroup rendered="#{empty personHelper.entityList}">
				<h:messages style="color:Red;"/>
				<br />
				Ingrese un criterio de busqueda
				<br />
				<br />
				<br />
			</h:panelGroup>
			
			<rich:dataGrid id="personGrid" value="#{personHelper.entityList}"
			rendered="#{not empty personHelper.entityList}" var="person"
			elements="#{mantUISettingsHelper.numElements}" columns="2" width="100%">
				<f:facet name="header">
					<rich:datascroller maxPages="15"></rich:datascroller>
				</f:facet>
				<f:facet name="footer">
					<rich:datascroller maxPages="15"></rich:datascroller>
				</f:facet>
				
				<table style="width: 100%">
					<tr valign="top">
						<td width="80%">
							<h:panelGrid columns="2">
								<h:outputText value="No. de Identidad: " />
								<h:outputText value="#{person.identity}" />
								
								<h:outputText value="Apellidos: " />
								<h:outputText value="#{personHelper.lastNames(person)}" />
								
								<h:outputText value="Nombres: " />
								<h:outputText value="#{personHelper.names(person)}" />
								
								<h:outputText value="Fecha de Nacimiento: " />
								<h:outputText value="#{person.dob}" />
								
								<h:outputText value="RTN: " />
								<h:outputText value="#{person.rtn}" />
			
								<h:outputText value="Sexo: " />
								<h:outputText value="#{personHelper.gender(person)}" />
								
								<h:outputText value="Nacionalidad: " />
								<h:outputText value="#{person.nationality}" />
							</h:panelGrid>
						</td>
						<td>
							<h:panelGrid columns="1">
								<a4j:commandLink
									value="Seleccionar"
									rendered="#{personHelper.selecting}"
									action="#{personHelper.select(person)}"
									reRender="#{personHelper.reRenderComponents}"
									oncomplete="#{rich:component(selectionPanelName)}.hide();">
								</a4j:commandLink>
								<a4j:commandLink
									value="Editar"
									action="#{personHelper.edit(person)}"
									reRender="frmEditNatPerson"
									oncomplete="#{rich:component('editNatPersonDlg')}.show();">
								</a4j:commandLink>
								<a4j:commandLink
									value="Ver detalles"
									action="#{personHelper.view(person)}"
									reRender="frmEditNatPerson"
									oncomplete="#{rich:component('editNatPersonDlg')}.show();">
								</a4j:commandLink>
							</h:panelGrid>
						</td>
					</tr>
				</table>
			</rich:dataGrid>
		</h:form>
	</ui:define>
	
	<ui:define name="natPersonRes">
		<ui:include src="natPersonDlgs.xhtml">
			<ui:param name="resultList" value="personGrid" />
		</ui:include>
	</ui:define>
	
	
	<!-- LEGAL PERSON STUFF -->
	<ui:define name="legalPersonTlbMainControls">
		<rich:toolBar height="25" itemSeparator="line">
			<rich:toolBarGroup>
				<h:form>
					<h:outputText value="#{messages['txt.quick_search']}   " style="font-weight:bold;" />
					<h:selectOneMenu value="#{legalPersonHelper.searchSelector}">
						<f:selectItem itemValue="#{legalPersonHelper.BY_RTN}" itemLabel="RTN"/>
						<f:selectItem itemValue="#{legalPersonHelper.BY_NAME}" itemLabel="Nombre"/>
					</h:selectOneMenu>
					<h:outputText value="  " />
					<h:inputText value="#{legalPersonHelper.searchText}" />
					<h:outputText value="  " />
					<a4j:commandButton
						value="#{messages['txt.search']}"
						action="#{legalPersonHelper.quickSearch}"
						reRender="frmLegalPersonGrid">
					</a4j:commandButton>
				</h:form>
			</rich:toolBarGroup>
			<rich:toolBarGroup>
				<h:form>
					<a4j:commandButton
						value="Agregar"
						action="#{legalPersonHelper.addNew}"
						reRender="frmEditLegalPerson"
						oncomplete="#{rich:component('editLegalPersonDlg')}.show();">
					</a4j:commandButton>
				</h:form>
			</rich:toolBarGroup>
		</rich:toolBar>
	</ui:define>
	
	<ui:define name="legalPersonResultGrid">
		<h:form id="frmLegalPersonGrid">
			<h:panelGroup rendered="#{empty legalPersonHelper.entityList}">
				<h:messages style="color:Red;"/>
				<br />
				<br />
				Ingrese un criterio de busqueda
				<br />
				<br />
				<br />
			</h:panelGroup>
			
			<rich:dataGrid id="personGrid" value="#{legalPersonHelper.entityList}"
			rendered="#{not empty legalPersonHelper.entityList}" var="person"
			elements="#{mantUISettingsHelper.numElements}" columns="2" width="100%">
				<f:facet name="header">
					<rich:datascroller maxPages="15"></rich:datascroller>
				</f:facet>
				<f:facet name="footer">
					<rich:datascroller maxPages="15"></rich:datascroller>
				</f:facet>
				
				<table style="width: 100%">
					<tr valign="top">
						<td width="80%">
							<h:panelGrid columns="2">
								<h:outputText value="RTN: " />
								<h:outputText value="#{person.rtn}" />

								<h:outputText value="Nombres: " />
								<h:outputText value="#{person.name}" />

								<h:outputText value="Telefono(s): " />
								<h:outputText value="#{person.phones}" />
								
								<h:outputText value="email(s): " />
								<h:outputText value="#{person.emails}" />
							</h:panelGrid>
						</td>
						<td>
							<h:panelGrid columns="1">
								<a4j:commandLink
									value="Seleccionar"
									rendered="#{legalPersonHelper.selecting}"
									action="#{legalPersonHelper.select(person)}"
									reRender="#{legalPersonHelper.reRenderComponents}"
									oncomplete="#{rich:component(selectionPanelName)}.hide();">
								</a4j:commandLink>
								<a4j:commandLink
									value="Editar"
									action="#{legalPersonHelper.edit(person)}"
									reRender="frmEditLegalPerson"
									oncomplete="#{rich:component('editLegalPersonDlg')}.show();">
								</a4j:commandLink>
								<a4j:commandLink
									value="Ver detalles"
									action="#{legalPersonHelper.view(person)}"
									reRender="frmEditLegalPerson"
									oncomplete="#{rich:component('editLegalPersonDlg')}.show();">
								</a4j:commandLink>
							</h:panelGrid>
						</td>
					</tr>
				</table>
			</rich:dataGrid>
		</h:form>
	</ui:define>
	
	<ui:define name="legalPersonRes">
		<ui:include src="legalPersonDlgs.xhtml">
			<ui:param name="resultList" value="personGrid" />
		</ui:include>
	</ui:define>
</ui:composition>
